#!/usr/bin/env python

def check(source):
	errors = []

	line = 0
	source = source.splitlines()
	while line < len(source):
		if len(source[line]) > 80:
			errors += ['Line %i contains more than 80 characters.' % (line + 1)]
		line += 1
	return errors

if __name__ == '__main__':
	import os

	for dirname, dirnames, filenames in os.walk('.'):
		filenames = filter(lambda x : x[-2:] == '.c',filenames)
		for filename in filenames:
			filepath = os.path.join(dirname,filename)

			with open(filepath,'r') as sourcefile:
				source = sourcefile.read()

			errors = check(source)

			if len(errors) > 0:
				print 'In %s found %i errors:' % (filepath,len(errors))
				for error in errors:
					print error
